// 转让驳回
<template>
  <div class="transferRejection">
    <el-breadcrumb separator="/" class="bread-title">
      <el-breadcrumb-item :to="{ path: '/projectList' }">跟投项目管理</el-breadcrumb-item>
      <el-breadcrumb-item :to="{ path: '/transferManagement' }">跟投转让管理</el-breadcrumb-item>
      <el-breadcrumb-item>驳回</el-breadcrumb-item>
    </el-breadcrumb>
    <div class="part">
      <div class="title">转让人信息</div>
      <div class="content">
        <p>
          <span>转让人姓名：</span>
          <span>{{assignor.staffName}}</span>
        </p>
        <p>
          <span>工号：</span>
          <span>{{assignor.staffCode}}</span>
        </p>
        <p>
          <span>业务线：</span>
          <span>{{assignor.businessLineName}}</span>
        </p>
        <p>
          <span>部门：</span>
          <span>{{assignor.departmentName}}</span>
        </p>
        <p>
          <span>职位：</span>
          <span>{{assignor.stationName}}</span>
        </p>
      </div>
    </div>
    <div class="part">
      <div class="title">受让人信息</div>
      <div class="content">
        <p>
          <span>受让人姓名：</span>
          <span>{{assignee.staffName}}</span>
        </p>
        <p>
          <span>工号：</span>
          <span>{{assignee.staffCode}}</span>
        </p>
        <p>
          <span>业务线：</span>
          <span>{{assignee.businessLineName}}</span>
        </p>
        <p>
          <span>部门：</span>
          <span>{{assignee.departmentName}}</span>
        </p>
        <p>
          <span>职位：</span>
          <span>{{assignee.stationName}}</span>
        </p>
      </div>
    </div>
    <div class="part">
      <div class="title">转让信息</div>
      <div class="content">
        <p>
          <span>项目名称：</span>
          <span>{{detailInfo.projectName}}</span>
        </p>
        <p>
          <span>跟投金额：</span>
          <span>￥{{detailInfo.investMoney | numFormat}}</span>
        </p>
        <p>
          <span>跟投份额：</span>
          <span>{{detailInfo.investNum}}份</span>
        </p>
      </div>
      <div class="content">
        <p>
          <span>确认状态：</span>
          <span v-show="detailInfo.confirmationStatus == 0">待确认</span>
          <span v-show="detailInfo.confirmationStatus == 1">已确认</span>
          <span v-show="detailInfo.confirmationStatus == 2">驳回</span>
        </p>
        <p>
          <span>确认时间：</span>
          <span>{{detailInfo.confirmationTime}}</span>
        </p>
        <p></p>
      </div>
      <div class="opinion">
        <div>驳回原因：</div>
        <textarea name="opinion" id="" cols="150" rows="10" maxlength='100' v-model="opinions"></textarea>
      </div>
    </div>
    <div class="btn">
      <el-button type="primary" @click="handleReject">驳回</el-button>
      <el-button type="primary" @click="handleCancle">取消</el-button>
    </div>
  </div>
</template>

<script>
import api from '@/api/apiPath'
export default {
  name:'transferRejection',
  data(){
    return {
      radio: '1',
      assignee:{},
      detailInfo:{},
      assignor:{},
      opinions:'',
    }
  },
  filters:{
    numFormat(val ){
      val += ''
      let x = val.split('.');
      let x1 = x[0] 
      let x2 = x.length > 1 ? '.' + x[1] : ''
      var rgx = /(\d+)(\d{3})/  
      while (rgx.test(x1)) {  
      x1 = x1.replace(rgx, '$1' + ',' + '$2')
      }
      return x1 + x2
    }
  },
  created(){
    this.getDetail()
  },
  methods:{
    // 基本信息
    getDetail(){
      this.axios.get(api.selectTransferDetail + '/' + this.$route.query.id).then((res)=>{
        this.id = res.data.data.id
        if(res.data.data.assignor){
          this.assignor = res.data.data.assignor
        }
        if(res.data.data.assignee){
          this.assignee = res.data.data.assignee
        }
        this.detailInfo = res.data.data
      })
    },
    // 取消
    handleCancle(){
      this.$router.push('/transferManagement')
    },
    // 驳回
    handleReject(){
      if(!this.opinions){
        return this.$message('请填写驳回原因')
      }
      this.axios.post(api.rejectTransfer + `?id=${this.$route.query.id}&opinions=${this.opinions}`).then((res=>{
        if(res.data.code == 200){
          this.$message('已驳回审核')
          this.$router.push('transferManagement')
        }
        console.log(res)
      }))
    }
  }
}
</script>

<style lang='stylus'>
.transferRejection{
  .bread-title{
    height:30px;
    font-size:16px;
  }
  min-height :100%;
  .title{
    font-size :18px;
    font-weight :700;
  }
  .part{
    margin-bottom :30px;
  }
  .content{
    display :flex;
    p{
      flex:1;
      font-size :15px;
    }
  }
  .opinion{
    margin-top :30px;
  }
  .opinion div{
    margin-bottom  :20px;
  }
  .btn{
    padding-left:30%;
    box-sizing :border-box;
  }

}
</style>
